@use '../variables';
@use '../mixins';

@include mixins.b(rating) {
  --color: var(--#{variables.$prefix}rating-color, var(--#{variables.$prefix}color-warning));
  --size: var(--#{variables.$prefix}rating-size, 1.25rem);
  --gutter-x: var(--#{variables.$prefix}rating-gutter-x, 0px);

  position: relative;
  display: inline-flex;
  align-items: center;
  font-size: var(--size);
  color: var(--color);
  vertical-align: top;

  @include mixins.when(disabled) {
    pointer-events: none;
    filter: opacity(50%);
  }

  @include mixins.m(read-only) {
    pointer-events: none;
  }

  @include mixins.e(star) {
    position: relative;
    transition: transform var(--#{variables.$prefix}animation-duration-fast) linear;

    & + & {
      margin-left: var(--gutter-x);
    }

    &:hover,
    &:focus-within {
      transform: scale(1.2);
    }
  }

  @include mixins.e(input) {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    margin: 0;
    appearance: none;
    cursor: pointer;

    @include mixins.m(half) {
      z-index: 5;
      width: 50%;
    }
  }

  @include mixins.e(icon) {
    color: var(--#{variables.$prefix}background-color-img);
    transition: color var(--#{variables.$prefix}animation-duration-fast) linear;

    @include mixins.when(checked) {
      color: inherit;
    }

    @include mixins.m(half) {
      position: absolute;
      top: 0;
      left: 0;
      width: 50%;
      height: 100%;
      overflow: hidden;
    }
  }
}
